/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package com.objectcarpentry.kaylee.impl;

import java.net.URI;
import java.util.Collection;

import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import com.objectcarpentry.kaylee.IPlayableFilter;
import com.objectcarpentry.kaylee.IPlayer;
import com.objectcarpentry.kaylee.IPlaylistController;
import com.objectcarpentry.kaylee.KayleePackage;
import com.objectcarpentry.kaylee.Library;
import com.objectcarpentry.kaylee.Playlist;
import com.objectcarpentry.kaylee.Track;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Library</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link com.objectcarpentry.kaylee.impl.LibraryImpl#getElements <em>Elements</em>}</li>
 *   <li>{@link com.objectcarpentry.kaylee.impl.LibraryImpl#getPlaylists <em>Playlists</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class LibraryImpl extends AbstractPlaylistImpl<Track> implements Library {
	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public static final String copyright = "Copyright 2009. Felix Dorner.\nThis code is licensed under the Eclipse Public License v1.0\nhttp://www.eclipse.org/org/documents/epl-v10.html";

	/**
	 * The cached value of the '{@link #getElements() <em>Elements</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getElements()
	 * @generated
	 * @ordered
	 */
	protected EList<Track> elements;

	/**
	 * The cached value of the '{@link #getPlaylists() <em>Playlists</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPlaylists()
	 * @generated
	 * @ordered
	 */
	protected EList<Playlist> playlists;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected LibraryImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return KayleePackage.Literals.LIBRARY;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Track> getElements() {
		if (elements == null) {
			elements = new EObjectContainmentEList<Track>(Track.class, this, KayleePackage.LIBRARY__ELEMENTS);
		}
		return elements;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Playlist> getPlaylists() {
		if (playlists == null) {
			playlists = new EObjectContainmentEList<Playlist>(Playlist.class, this, KayleePackage.LIBRARY__PLAYLISTS);
		}
		return playlists;
	}

	

	/**
	 * <!-- begin-user-doc -->
	 * The name of a library is always "Library"
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public String getName() {
		return "Library";
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case KayleePackage.LIBRARY__ELEMENTS:
				return ((InternalEList<?>)getElements()).basicRemove(otherEnd, msgs);
			case KayleePackage.LIBRARY__PLAYLISTS:
				return ((InternalEList<?>)getPlaylists()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case KayleePackage.LIBRARY__ELEMENTS:
				return getElements();
			case KayleePackage.LIBRARY__PLAYLISTS:
				return getPlaylists();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case KayleePackage.LIBRARY__ELEMENTS:
				getElements().clear();
				getElements().addAll((Collection<? extends Track>)newValue);
				return;
			case KayleePackage.LIBRARY__PLAYLISTS:
				getPlaylists().clear();
				getPlaylists().addAll((Collection<? extends Playlist>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case KayleePackage.LIBRARY__ELEMENTS:
				getElements().clear();
				return;
			case KayleePackage.LIBRARY__PLAYLISTS:
				getPlaylists().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case KayleePackage.LIBRARY__ELEMENTS:
				return elements != null && !elements.isEmpty();
			case KayleePackage.LIBRARY__PLAYLISTS:
				return playlists != null && !playlists.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	@Override
	public boolean match(IPlayableFilter filter) {
		return false;
	}
	
	
	

} //LibraryImpl
